import axios from 'axios';
import { apiUrl } from './config';
// 重新创建 axios 实例，确保使用正确的配置
export const apiClient = axios.create({
  baseURL: apiUrl,
  headers: {
    'Content-Type': 'application/json',
  },
  withCredentials: true,
});

// 添加请求拦截器，打印每个请求的详细信息
apiClient.interceptors.request.use(
  function (config) {
    console.log('发送请求:', {
      method: config.method,
      url: config.url,
      baseURL: config.baseURL,
      fullURL: `${config.baseURL}${config.url}`,
      params: config.params,
      data: config.data
    });
    return config;
  },
  function (error) {
    return Promise.reject(error);
  }
); 